package com.kk.base.entity.home;

import com.kk.base.annotion.ValidateEntity;
import com.kk.base.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

import static com.kk.base.entity.admin.User.ADMIN_USER_STATUS_ENABLE;


/**
 * 前台用户实体类
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "home_user")
@EntityListeners(AuditingEntityListener.class)
@ToString
@Data
public class HomeUser extends BaseEntity {


    @ValidateEntity(required = true, errorRequiredMsg = "手机号不能为空!")
    @Column(name = "mobile", nullable = false)
    private String mobile;//手机号

    @Column(name = "password", nullable = false)
    private String password; //密码

    @ValidateEntity(required = true, errorRequiredMsg = "用户名不能为空!")
    @Column(name = "name", nullable = false)
    private String name;//用户名

    @Column(name = "email", nullable = false)
    private String email;//用户邮箱

    @ValidateEntity(required = true, errorRequiredMsg = "生日不能为空!")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Temporal(TemporalType.DATE)
    @Column(name = "birthday", nullable = false)
    private Date birthday; //生日

    @ValidateEntity(required = true, errorRequiredMsg = "性别不能为空!")
    @Column(name = "sex", nullable = false)
    private Integer sex; //性别

    @ValidateEntity(required = true, errorRequiredMsg = "地址不能为空!")
    @Column(name = "address", nullable = false)
    private String address; //地址（省市区）

    @ValidateEntity(required = true, errorRequiredMsg = "详细地址不能为空!")
    @Column(name = "detailed_address", nullable = false)
    private String detailedAddress; //详细地址

    @Column(name = "status", length = 1)
    private int status = ADMIN_USER_STATUS_ENABLE;//用户状态,默认可用

}
